package ooday03.animal;




public class Test {
    public static void main(String[] args) {
        Animal[] animals = new Animal[5];
        animals[0] = new Dog("黑豆", 3, "黑");
        animals[1] = new Dog("小黄", 4, "黄");
        animals[2] = new Chick("坤坤", 23, "白");
        animals[3] = new Chick("小红", 4, "红");
        animals[4] = new Fish("小金", 2, "金");

        for (int i = 0; i < animals.length; i++) {

            if(animals[i] instanceof Dog){
                Dog dog = (Dog)animals[i];
                dog.lookHome();
                dog.swim();
            }
            if(animals[i] instanceof Chick){
                Chick chick = (Chick) animals[i];
                chick.layEgg();
                chick.drink();
            }
            if(animals[i] instanceof Swim){
                Swim s = (Swim) animals[i];
                s.swim();
            }


        }
    }
}
